#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int pivotIndex(int* nums, int numsSize)
{
    int i = 0;
    int sum = 0;
    for (i = 1; i < numsSize; i++)
    {
        sum += nums[i];
    }
    if (sum == 0)
        return 0;
    for (i = 1; i < numsSize - 1; i++)
    {
        int x = 0;
        int y = 0;
        int j = 0;
        for (j = 0; j < i; j++)
        {
            x += nums[j];
        }
        for (j = i + 1; j < numsSize; j++)
        {
            y += nums[j];
        }
        if (x == y)
        {
            return i;
        }
    }
    sum = 0;
    for (i = 0; i < numsSize - 1; i++)
    {
        sum += nums[i];
    }
    if (sum == 0)
        return numsSize - 1;
    return -1;
}

int main()
{
	int nums[] = { -1,-1,0,1,0,-1 };
	int len = sizeof(nums) / sizeof(nums[0]);
	int ret = pivotIndex(nums, len);
	printf("%d", ret);

	return 0;
}